The HANDS ON Wizard manual Page 1 Updated March, 1995 This Product is Shareware, if you continue to use it Please Legalise your usage through Registration. _______ ____|__ | (R) --| | |------------------- | ____|__ | Association of | | |_| Shareware |__| o | Professionals -----| | |--------------------- |___|___| Member Table of Contents page # 1. Introduction 1 2. Script Files 2 2.1 Script Commands 3 2.2 An example 6 3. Using Wizard with Batch Files 11 4. SHOW - debugging scripts 11 5. Feeding the Wizard 13 6. The Apprentice 15 7. SUPPORT and the ASP 15 Appendix A - Special keys 16 Appendix B - Acknowledgments and history 18 Appendix C - ShareWare Vendor Notice (if any) 1. Introduction The Wizard is a program which will run any other program, and make it appear to that program that a user is typing commands at the keyboard. Actually the "typing" is done automatically by the Wizard as specified in a script file. The Wizard's scripts also allow it to monitor the contents of the computer's screen and elapsed time and take actions based on the screen contents and/or the time. These capabilities help you quite a bit when you start to automate file transfers and such matters. The Wizard should work with any program that uses DOS or the BIOS for keyboard input, or that uses the BIOS The HANDS ON Wizard manual Page 2 data area directly. However, programs that interface directly with the keyboard hardware will not work with it. Fortunately very few programs work this way. Wizard is commonly abbreviated as WIZ, and you can also just call it 'Wizard'. There are two primary Wizard distributions: 1) with the Hands On remote access package. 2) on its own. Typical usage of Wizard might be: (Wizard is abbreviated as WIZ here) WIZ script.scr kermit which would cause Wizard to read in the script file name 'script.scr' and then run kermit. While kermit was running, Wizard would "type" whatever was in the script file. When kermit terminated (either because the script file included a command to terminate the program, or because the user manually terminated kermit) Wizard would also terminate. This has the benefit that the user does not need to worry about whether a TSR is loaded; Wizard is loaded for just long enough to run the application, and unloads itself as soon as the application has finished. If for any reason more than one application needs to be used, Wizard can be run as: WIZ script.scr command which will run another copy of the DOS command interpreter. The Wizard script can then run as many applications as necessary, and finish by entering: EXIT to leave the command interpreter (and hence also terminate Wizard). You can pass a complete command line with parameters to your application - for example, if you would normally start an application as: program arg1 arg2 arg3 then simply use: WIZ script.scr program arg1 arg2 arg3 2. Script Files Normally, script files contain ordinary letters: each letter is interpreted as the corresponding key on the keyboard. Thus a The HANDS ON Wizard manual Page 3 script: abc would cause the keys 'a', 'b' and 'c' to be "typed". However, end-of-line is ignored in script files, so there needs to be some way to specify the key (and indeed the many other special keys that are not normal printable ASCII characters). These are indicated by enclosing a description of the key inside '<' and '>'. A number of special keys are permitted. Some examples follow: There is a complete list in Appendix A. These special keys must be entered exactly as shown (with the exception that case is not significant): for example, Wizard will not recognize or - it must be or etc. There is no need to enclose normal printable characters within '<' and '>', although it is permitted. For example, the following two lines are equivalent: dir Two characters have a special meaning in script files: '<' and '{'. These must be written as <<> and <{> respectively. Blank spaces in script files will be "typed" as the key whenever they appear. This can be confusing if there is trailing white space at the end of a line, or if you leave a blank between two commands (see below). The output of the SHOW command (again, see below) will make these space characters more obvious... 2.1 Script Commands In addition to keys, Wizard provides a number of commands to do more exotic things such as checking for text on the screen so that the "typing" can be more intelligent. You can use the cpscrn tool, PRTSCR (print screen), or we can provide other screen location and grabbing tools as needed. Commands are enclosed in '{' and '}'. The following commands are supported: The HANDS ON Wizard manual Page 4 AFTER seconds Go to a label if timer has been running for more than a specified number of seconds. For example, here is a script to wait until it finds C:\> in the bottom left corner of the screen, but with a timeout after 5.5 seconds: {zero} {label loop} {after 5.5 abort} {not_at (24,0) "C:\\>" loop} {label abort} Notice that the timer is zeroed before the start of the loop. AT (row, col) Go to a label if the text at a specified position on the screen matches. Syntax is {at (line,column) "text" label}. Line and column are numbered from 0. The text to match is enclosed in quotes. To match a double quote, use \". To match a \, use \\. For example, the following script waits until it finds C:\> or C:\DOS> in the bottom left corner of the screen: {label loop} {at (24,0) "C:\\>" root} {at (24,0) "C:\\DOS>" dos} {goto loop} (Naturally "root" and "dos" must be labels elsewhere in the script!) BEFORE time Go to a label if timer has been running for less than a specified number of seconds. For example, to go to a label "loop" if the timer has been running less than 10 seconds use: {before 10.0 loop} CUT Record the contents of the screen in a given location. The specified number of characters, starting at the specified location, will be saved for later playback using the "paste" command. The syntax is: {cut buffer (line,col) number} Example: {cut 1 (0,0) 20} to record 20 characters starting from the top left corner and store this in buffer number 1. The number of buffers is limited; currently it is 5 (0-4 inclusive). Trailing spaces The HANDS ON Wizard manual Page 5 are eliminated; however, if the entire text is all spaces then a single space is retained. DISABLE Disable the keyboard, so that the user cannot interfere with what is happening. The syntax is: {disable} Make sure you call {enable} afterwards, or the user will be locked out! ENABLE Enable the keyboard, so that the user can type normally. This is the default. However, if the user types while Wizard is "typing" the result is likely to be confusion! The syntax is: {enable} END Terminate the "typing" of keys. Interpretation of the script will just stop here. This happens automatically at the end of the script, but saves using an artificial {goto end} if the end of the script is error handling code. Example: {end} GOTO Goto label. Instead of moving on to the next key or command in the script, go to the specified label and continue from there. For example, the following script will keep on "typing" dir indefinitely: {label loop} dir {goto loop} HOLD Hold shift keys. Some applications (such as Hands On) check the status of various shift keys. The possible shift keys are: left, right, ctrl or control, alt, num (for numlock), scroll, caps and insert. For example, to "hold down" left shift, right shift, control and alt, use: {hold left right ctrl alt} This command does not change the status of any of the shifts that are not mentioned. See "release" for key release. LABEL Record the position of a named label (see the other commands for uses). For example, to create a label named "loop" use: {label loop} The HANDS ON Wizard manual Page 6 Label names are case sensitive. Normally label names cannot be reused. However, if the label name starts with a '$' character then the name can be reused, and any reference will be to the most recent label (or to the first one if no labels with this name have been encountered yet). NOT_AT Go to a label if the text at a specified position on the screen does not match. Syntax is {not_at (line,column) "text" label}. Line and column are numbered from 0. The text to match is enclosed in quotes. To match a double quote, use \". To match a \, use \\. For example, the following script waits until it finds C:\> in the bottom left corner of the screen: {label loop} {not_at (24,0) "C:\\>" loop} PASTE Play back the characters saved by the most recent "cut" command as if typed from the keyboard. The syntax is: {paste buffer} Example: {paste 1} to paste back the contents of buffer 1. REBOOT Reboot the PC. This is a drastic way to recover from an application that is not responding as expected! Usage: {reboot} RELEASE Release shift keys. This is the opposite of "hold"; it releases the specified keys. For example, to release num lock use: {release num} This command does not change the status of any of the shifts that are not mentioned. See "hold" for a list of the shift keys supported. RESULT Set the DOS result code. This is used to return an "errorlevel" that can be used from a DOS batch file. For example, to return a result code of 2 use: {result 2} SPEED Set "typing" speed. Normally, one key is "typed" every 0.055 seconds, and this is the fastest possible speed. However, if your application requires slower typing, the gap The HANDS ON Wizard manual Page 7 between characters can be set anywhere up to 14 seconds. For example, to type at 4 keys per second, use: {speed 0.25} WAIT Wait for X seconds (0 < X < 117,951,481). For example, to pause for half a second, use: {wait 0.5} Alternatively, wait for a given clock time. For example, to wait until 3:30:25 in the afternoon, use: {wait 15:30:25} ZERO Zero timer (see the following commands for uses). For example: {zero} 2.2 An example Here is a real life example of a script file which will run Hands On (eg HO.exe) to retrieve a file automatically from a remote PC: {zero} {result 4} {label $wait} {after 60 continue} {not_at (24,0) "C:\\" $wait} {hold left right ctrl alt} {label $wait} {not_at (23,66) "Press key: " $wait} {release left right ctrl alt} temp.dat {zero} {label $wait} {after 10 abort_start} {not_at (5,18) "File Transfer in Progress..." $wait} {label ok} {zero} {label $wait} {after 600 abort_mid} {at (0,73) "Partial" abort_no_file} {at (5,18) "File Transfer in Progress..." $wait} {result 0} {label continue} The HANDS ON Wizard manual Page 8 {hold left right ctrl alt} {label $wait} {not_at (23,66) "Press key: " $wait} {release left right ctrl alt} 3 {end} {label abort_start} {result 1} {zero} {label $wait} < > {at (4,0) " Type to continue:" escape} {at (5,18) "File Transfer in Progress..." ok} {after 10 continue} {goto $wait} {label escape} {goto continue} {label abort_mid} {result 2} 1 {zero} {label $wait} {at (2,0) " Remove incomplete" yes} {after 5 continue} {goto $wait} {label yes} y {goto continue} {label abort_no_file} {result 3} 1 {goto continue} Now the same script with an explanation: Start by waiting for Hands On (HO) to dial, establish a link, take control of the remote PC, and transmit the screen of the remote PC. The remote PC is assumed to be at the DOS command line prompt, and this prompt is assumed to be at the bottom left corner of the screen. {zero} Zero timer so that the "after" command will work correctly. {result 4} The HANDS ON Wizard manual Page 9 If a timeout occurs, then we want to return errorlevel 4 to DOS. {label $wait} Use a reusable label name (purely to save needing to invent a whole lot of unique label names). {after 60 continue} If the desired text does not appear within 60 seconds then give up. {not_at (24,0) "C:\\" $wait} If the desired text has not yet appeared then go back to the start of the loop. Bring up HO's local menu, select a file transfer, and specify the name of the file. {hold left right ctrl alt} To get HO's attention, all four shift keys must be held down at one time. {label $wait} {not_at (23,66) "Press key: " $wait} Loop until the local menu appears... {release left right ctrl alt} No need for the shift keys any more. Select a file download. temp.dat Specify the name of the file to be downloaded. Wait for the file transfer to commence. {zero} {label $wait} {after 10 abort_start} If it takes more than 10 seconds then something has gone badly The HANDS ON Wizard manual Page 10 wrong, so give up! {not_at (5,18) "File Transfer in Progress..." $wait} Wait for the file transfer to complete. {label ok} This label is so we can resume if we find we can during error processing. {zero} {label $wait} {after 600 abort_mid} If the file transfer has taken more than 10 minutes then give up and abort it. {at (0,73) "Partial" abort_no_file} If the file did not exist (and hence could not be downloaded) then give up. {at (5,18) "File Transfer in Progress..." $wait} Keep waiting as long as the transfer is happening. Success! The file transfer has completed. Terminate the session. {result 0} Return a success errorlevel to DOS. {label continue} Resume here after error processing. {hold left right ctrl alt} {label $wait} {not_at (23,66) "Press key: " $wait} Get into HO's local command menu. {release left right ctrl alt} 3 Exit and hang up. {end} The HANDS ON Wizard manual Page 11 Stop here (just in case HO takes a moment to terminate, so that we don't go on and start typing any of the error processing stuff). The file transfer never got started. {label abort_start} {result 1} {zero} {label $wait} < > The space key (actually any key would do) causes HO to give up waiting for the transfer to commence. {at (4,0) " Type to continue:" escape} This is part of the message HO gives when a transfer was aborted this way... {at (5,18) "File Transfer in Progress..." ok} We were just too impatient! The transfer has started after all. Resume normal operations. {after 10 continue} If there is no response then try to see if we can terminate anyway... (hopefully this would never be required) {goto $wait} {label escape} {goto continue} The file transfer took too long (presumably due to data transmission errors). {label abort_mid} {result 2} 1 Option 1 tells HO to abort the transfer. {zero} {label $wait} {at (2,0) " Remove incomplete" yes} HO should ask if we want to remove the incomplete file (which we do). {after 5 continue} The HANDS ON Wizard manual Page 12 If no response after 5 seconds then try to abort anyway... {goto $wait} {label yes} y {goto continue} The file did not exist on the remote PC. {label abort_no_file} {result 3} 1 Abort the transfer, then terminate HO. {goto continue} If a script file contains any error, then Wizard will reject it and immediately return an errorlevel of 255. Use SHOW to help locate the cause of the error (look for SHOW below ). 3. Using Wizard with Batch Files Because Wizard can return an errorlevel for DOS, it is possible for a batch file to determine what went on during a Wizard (wiz.exe) session. For example, here is a batch file that might be used with the example Hands On (ho.exe) file transfer above: @echo off WIZ sample.scr HO.exe site.HO if errorlevel 255 goto bad_script if errorlevel 4 goto no_HO if errorlevel 3 goto abort_no_file if errorlevel 2 goto abort_mid if errorlevel 1 goto abort_start echo Success! goto done :bad_script echo Bad Wizard script goto done :no_HO echo Could not establish HO link goto done :abort_no_file echo Aborted due to file not found goto done :abort_mid echo Aborted mid-file goto done The HANDS ON Wizard manual Page 13 :abort_start echo Aborted before starting transfer goto done :done 4. SHOW - debugging scripts SHOW is a program to assist with debugging Wizard scripts. Usage is SHOW